package com.company;

public class FormateByte {
    public static void main(String[] args) {
        System.out.println(formateByte(15323000));
    }

    static String formateByte(long bytes){
        if (bytes < 1024){
            return bytes+" B";
        }
        if (bytes > 1024 && bytes < Math.pow(1024,2)){
            return bytes/1024+" KB";
        }
        if (bytes > Math.pow(1024,2) && bytes < Math.pow(1024,3)){
            return bytes/Math.pow(1024,2)+" MB";
        }
        else
            return bytes/Math.pow(1024,3)+" GB";
    }
}
